package simpleness;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Task2042 {
    public static void main(String[] args) {
        String s = "1 box has 1 blue 4 red 6 green and 12 yellow marbles";
        boolean b = new Task2042().areNumbersAscending02(s);
        System.out.println(b);
    }

    public boolean areNumbersAscending02(String s) {
        Matcher matcher = Pattern.compile("\\d+").matcher(s);
        int top = 0;
        while (matcher.find()) {
            int anInt = Integer.parseInt(matcher.group());
            if (anInt <= top) {
                return false;
            }else {
                top = anInt;
            }
        }
        return true;
    }

    public boolean areNumbersAscending01(String s) {
        int top = 0;
        String[] strings = s.split(" ");
        for (int i = 0; i < strings.length; i++) {
            char c = strings[i].charAt(0);
            if (c > '0' && c <= '9') {
                int anInt = Integer.parseInt(strings[i]);
                if (anInt <= top) {
                    return false;
                } else {
                    top = anInt;
                }
            }
        }
        return true;
    }
}